home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_065 / prep / sieve.p < prev    next >
Text File  |  1992-05-06  |  686b  |  40 lines

  1. c Sieve benchmark in fortran.  Translated directly from a c
  2. c version (?) without much thought, to illustrate a few prep
  3. c facilities.  Not written for speed, but it should work.
  4.  
  5. #include "premac.h"
  6. : S        8190 ;
  7. : do_while(l)    begin
  8.         while (l) ;
  9.  
  10. do limits [ (0, S) ]
  11.  
  12.     integer f(0:S)
  13.     integer i, p, k, c, n
  14.  
  15.     do n = 1, 10
  16.        c = 0
  17.        f(#) = 1
  18.  
  19.        do i = 0, S
  20.           if ( f(i) != 0 ) then
  21.              p = 2*i + 3
  22.              k = i + p
  23.  
  24. c    this loop will be faster as a normal do loop on a vector machine
  25.              do_while ( k <= S )
  26.                 f(k) = 0
  27.                 k = k + p
  28.              again
  29.  
  30.              c = c + 1
  31.           end if
  32.        end do
  33.  
  34.     end do
  35.  
  36.     write(*,*) c, ' primes'
  37.  
  38.     stop
  39.     end
  40.